package com.hu.zhcc.shiro.controller.xsx;


import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hu.zhcc.shiro.entity.xsx.XsxTInterposeClassify;
import com.hu.zhcc.shiro.entity.xsx.XsxTMemberInfo;
import com.hu.zhcc.shiro.service.xsx.TInterposeClassifyService;
import com.hu.zhcc.shiro.service.xsx.TMemberInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 人群分类 前端控制器
 * </p>
 *
 * @author xsx
 * @since 2021-06-19
 */
@RestController
@RequestMapping("/tInterposeClassify")
public class TInterposeClassifyController {
    @Autowired
    TInterposeClassifyService tInterposeClassifyService;
    @Autowired
    TMemberInfoService tMemberInfoService;


    @PutMapping("/{flid}/{rq}/{jks}")
    private int qryy(@PathVariable("flid") Integer flid, String rq,Integer jks){
        XsxTInterposeClassify t=new XsxTInterposeClassify();
        t.setInterposeStatus("健康师已分类");
        Gson gson=new Gson();
        String[] sz =gson.fromJson(rq, new TypeToken<String[]>() {}.getType());
        String str="";
        for(String num : sz){
            str=str+" "+num+" ";
        }
        t.setPeopleClassify(str);
        t.setTMemberId(flid);
        int i1 = tInterposeClassifyService.updateClassify(t);
        XsxTMemberInfo tMemberInfo=new XsxTMemberInfo();
        tMemberInfo.setHealthFlId(jks);
        tMemberInfo.setTMemberId(flid);
        int i = tMemberInfoService.updateJks(tMemberInfo);
        if(i1>0 && i>0){
            return 1;
        }
        return 0;
    }

}

